package net.lab1024.sa.admin.module.business.wms.stock.controller;

import net.lab1024.sa.admin.module.business.wms.stock.domain.form.StockAddForm;
import net.lab1024.sa.admin.module.business.wms.stock.domain.form.StockQueryForm;
import net.lab1024.sa.admin.module.business.wms.stock.domain.form.StockUpdateForm;
import net.lab1024.sa.admin.module.business.wms.stock.domain.vo.StockVO;
import net.lab1024.sa.admin.module.business.wms.stock.service.StockService;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import cn.dev33.satoken.annotation.SaCheckPermission;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;

/**
 * 库存信息表（单租户版） Controller
 *
 * @Author ADog
 * @Date 2025-09-20 15:55:03
 * @Copyright 1.0
 */

@RestController
@Tag(name = "库存信息表（单租户版）")
public class StockController {

    @Resource
    private StockService stockService;

    @Operation(summary = "分页查询 @author ADog")
    @PostMapping("/stock/queryPage")
    @SaCheckPermission("stock:query")
    public ResponseDTO<PageResult<StockVO>> queryPage(@RequestBody @Valid StockQueryForm queryForm) {
        return ResponseDTO.ok(stockService.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author ADog")
    @PostMapping("/stock/add")
    @SaCheckPermission("stock:add")
    public ResponseDTO<String> add(@RequestBody @Valid StockAddForm addForm) {
        return stockService.add(addForm);
    }

    @Operation(summary = "更新 @author ADog")
    @PostMapping("/stock/update")
    @SaCheckPermission("stock:update")
    public ResponseDTO<String> update(@RequestBody @Valid StockUpdateForm updateForm) {
        return stockService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author ADog")
    @PostMapping("/stock/batchDelete")
    @SaCheckPermission("stock:delete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
        return stockService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author ADog")
    @GetMapping("/stock/delete/{stockId}")
    @SaCheckPermission("stock:delete")
    public ResponseDTO<String> batchDelete(@PathVariable Long stockId) {
        return stockService.delete(stockId);
    }
}
